/**
 * 2017年7月3日
 */
package org.textplantform.common;

import java.util.ArrayList;
import java.util.List;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.textplantform.common.api.mq.MessageConsumer;
import org.textplantform.common.api.mq.PlantformTextConsumer;
import org.textplantform.common.core.mq.BasePlantformKafkaConsumer;
import org.textplantform.common.core.mq.KafkaConsumerFactory;


/**
 * @author Alex
 *
 */
public class MQTest2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PlantformTextConsumer<ConsumerRecord<String,String>> consumer = KafkaConsumerFactory.getConsumer(Constant.Values.MQ_TOPIC);
		if(consumer instanceof BasePlantformKafkaConsumer){
			BasePlantformKafkaConsumer bpkc = (BasePlantformKafkaConsumer) consumer;
			bpkc.setMessageConsuemr(new MessageConsumer<ConsumerRecord<String,String>>() {
				@Override
				public void consume(Iterable<ConsumerRecord<String, String>> messages) {
					messages.forEach(System.out::println);
				}
				@Override
				public void consume(ConsumerRecord<String, String> message) {
					System.out.println(message);
				}
			} );
			bpkc.startSync();
		}
		
	}

}
